import request from '@/utils/request'
const asyncRoutes = require('../../../mock/api/basics/role/routes.js')

export function getRoutes() {
  return new Promise((resolve) => {
    resolve({
      code: '0',
      data: asyncRoutes
    })
  })
}

export function getRoles() {
  return new Promise((resolve) => {
    resolve({
      code: '0',
      data: [
        {
          key: 'admin',
          name: 'admin',
          description: '超级管理员,有权查看所有页面。',
          routes: asyncRoutes
        },
        {
          key: 'develop',
          name: 'develop',
          description: '开发者,有权查看所有页面',
          routes: asyncRoutes
        }
      ]
    })
  })
}

export function addRole(data) {
  return request({
    url: '/role',
    method: 'post',
    data
  })
}

export function updateRole(id, data) {
  return request({
    url: `/role/${id}`,
    method: 'put',
    data
  })
}

export function deleteRole(id) {
  return request({
    url: `/role/${id}`,
    method: 'delete'
  })
}
